package svc

import (
	"2210a/user-profile/userprofileapi/internal/config"
	"2210a/user-profile/userprofileapi/internal/middleware"
	"2210a/user-profile/userprofilerpc/userprofilerpcclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config              config.Config
	UserprofileRpc      userprofilerpcclient.Userprofilerpc
	UserTokenMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		UserprofileRpc:      userprofilerpcclient.NewUserprofilerpc(zrpc.MustNewClient(c.UserprofileRpc)),
		UserTokenMiddleware: middleware.NewUserTokenMiddleware().Handle,
	}
}
